﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HttpClientStudy.Model
{
    /// <summary>
    /// API 返回基类
    /// </summary>
    public class BaseResult
    {
        /// <summary>
        /// 接口返回代码
        /// </summary>
        public int Code { get; set; }

        /// <summary>
        /// 接口返回说明信息
        /// </summary>
        public string? Message { get; set; }

        /// <summary>
        /// 接口返回数据
        /// </summary>
        public object? Data { get; set; } = string.Empty;
    }

    /// <summary>
    /// API 泛型返回基类
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class BaseResult<T> : BaseResult
    {
        /// <summary>
        /// 创建返回基数
        /// </summary>
        /// <param name="data">泛型数据</param>
        /// <param name="code">编码</param>
        /// <param name="message">说明信息</param>
        /// <returns></returns>
        public static BaseResult<T> Create(T? data = default, int code = 0, string message = "")
        {
            return new BaseResult<T> { Data = data, Code = code, Message = message };
        }

        /// <summary>
        /// 泛型返回核心数据
        /// </summary>
        public new T? Data { get; set; }
    }
}
